<%@ page language="java" import="java.util.*"
	contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://www.rapid-framework.org.cn/rapid" prefix="rapid"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<rapid:override name="frame-header-style">
	<style>
.widthandhight {
	width: 100px;
	height: 100%;
}

</style>

</rapid:override>
<rapid:override name="frame-content">
	<blockquote class="layui-elem-quote">
		<span class="layui-breadcrumb" lay-separator="/"> <a
			href="user/index">首页</a> <a><cite>文章列表</cite></a>
		</span>
	</blockquote>
	<div class="layui-tab layui-tab-card">
	
		<form id="articleForm" method="post" action="article">
		文章标题: <input name="articleTitle" id="articleTitle" placeholder="输入文章名称" class="widthandhight" value="${articleTitle }">
		 <select name="articleParentCategoryId" id="articleParentCategoryId"  class="widthandhight">
                 
                    <option value="" >一级分类</option>
	                    <c:forEach items="${cateList}" var="c">
	                        <c:if test="${c.categoryPid==0}">
	                            <option value="${c.categoryId}"
	                            	<c:if test="${c.categoryId==articleParentCategoryId}">
	                            		selected
	                            	</c:if>
	                            >${c.categoryName}</option>
	                        </c:if>
	                        
	                    </c:forEach>
                    </select>
				<select name="articleChildCategoryId" id="articleChildCategoryId" class="widthandhight">
					
					<c:if test="${selectCategoryById!=null }">
						<option value="${selectCategoryById.categoryId }" selected id="smallCatgory">二级分类</option>
					</c:if>
					<c:if test="${selectCategoryById==null }">
						<option value="" selected id="smallCatgory">二级分类</option>
					</c:if>
				</select>
				
				<select name="articleStatus" id="articleStatus" class="widthandhight">
					<option value="" selected >选择状态</option>
					<option value="1"  >发布</option>
					<option value="0" >草稿</option>
				</select>
				大于此发布时间:<input type="date" name="articleUpdateTime" id="articleUpdateTime" value="${articleUpdateTime }"> 
			<input type="submit" value="查询" class="layui-btn layui-btn-mini">
			<input type="hidden" name="currentUrl" id="currentUrl" value="">
			<table class="layui-table">
				<colgroup>
					<col width="300">
					<col width="150">
					<col width="100">
					<col width="150">
					<col width="100">
					<col width="50">
				</colgroup>
				<thead>
					<tr>
						<th>标题</th>
						<th>所属分类</th>
						<th>状态</th>
						<th>发布时间</th>
						<th>操作</th>
						<th>id</th>
					</tr>
				</thead>
				<tbody>
		
					<c:forEach var="a" items="${pageInfo.list }" >
						<tr>
							<td>
								<a href="/article/33" target="_blank"> ${a.articleTitle }</a>
							</td>
							<td>
								<c:forEach var="cate" items="${a.categoryList }">
									
									<a href="/category/${cate.categoryId }" target="_blank">${cate.categoryName }</a> &nbsp; 
								</c:forEach>
								
								
							</td>
							<td>
								<c:if test="${a.articleStatus==1 }">
									<a href="/admin/article?status=1"> <span style="color: #5FB878;">已发布</span></a>
								</c:if>
								<c:if test="${a.articleStatus==0 }">
									<a href="/admin/article?status=1"> <span style="color: red;">草稿</span></a>
								</c:if>
								
							</td>
							<td><fmt:formatDate value="${a.articleUpdateTime }" pattern="yyyy/MM-dd hh:mm"/> </td>
							<td><a href="article/edit/${a.articleId }"
								class="layui-btn layui-btn-mini">编辑</a> <a
								href="article/delete/${a.articleId }" onclick="return confirm('确认要删除吗')"
								class="layui-btn layui-btn-danger layui-btn-mini">删除</a></td>
							<td>${a.articleId }</td>
						</tr>
					</c:forEach>
					
					
				</tbody>
			</table>
		</form>
		<nav class="navigation pagination" role="navigation">
			<div class="nav-links">
				<%@ include file="../page.jsp"%>
			</div>
		</nav>
	</div>
	
</rapid:override>
<rapid:override name="frame-footer-script">
	<script>
		$(".page-numbers").click(function(){
			var href=$(this).attr("href");
			var articleTitle = $("#articleTitle").val();
			var articleParentCategoryId = $("#articleParentCategoryId").val();
			var articleChildCategoryId = $("#articleChildCategoryId").val();
			var articleStatus = $("#articleStatus").val();
			var articleUpdateTime = $("#articleUpdateTime").val();
			if(articleTitle!=""){
				href+="&articleTitle=" +articleTitle; 
			}
			if(articleParentCategoryId!=""){
				href+="&articleParentCategoryId=" +articleParentCategoryId; 
			}
			if(articleChildCategoryId!=""){
				href+="&articleChildCategoryId=" +articleChildCategoryId; 
			}
			if(articleStatus!=""){
				href+="&articleStatus=" +articleStatus; 
			}
			if(articleUpdateTime!=""){
				href+="&articleUpdateTime=" +articleUpdateTime; 
			}
			$(this).attr("href",href);
		});
	
		$("#articleParentCategoryId").change(function(){
			var big=$("#articleParentCategoryId").val();
			$("#articleChildCategoryId").empty();
			$("#articleChildCategoryId").append("<option value=''>请选择二级分类</option>");
				$.ajax({
					url:"article/lianDong",
					dataType:"json",
					type:"post",
					data:{id:big},
					success:function(category){
						$.each(category,function(index,item){
							var str="<option value="+item.categoryId;
							str +=">"+item.categoryName+"</option>" ;
						    $('#articleChildCategoryId').prepend(str);//往下拉菜单里添加元素
						 });
					}
				});
		});
	</script>	
</rapid:override>

<%@ include file="../framework.jsp"%>